package com.baizan.daka.ui.activity

import android.content.Context
import android.content.Intent
import com.baizan.base.BaseActivity
import com.baizan.daka.mvp.model.bean.NewsDetailBean
import com.baizan.daka.mvp.model.bean.NewsInfoBean
import com.baizan.daka.ui.contract.NewsDesContract
import com.baizan.daka.ui.presenter.NewsDesPresenter
import com.baizan.daka.util.TimeUtil
import com.dianzan.daka.R
import kotlinx.android.synthetic.main.act_news_des.*

class NewsDesActivity : BaseActivity<NewsDesPresenter>(), NewsDesContract.View {
    var id: Long? = 0

    companion object {
        fun start(context: Context, id: Long) {
            val intent = Intent(context, NewsDesActivity::class.java)
            intent.putExtra("id", id)
            context.startActivity(intent)
        }
    }

    override fun initPresenter(): NewsDesPresenter = NewsDesPresenter(this)

    override fun layoutId(): Int = R.layout.act_news_des

    override fun initData() {
        id = intent.getLongExtra("id", 0);
    }

    override fun initView() {
    }

    override fun start() {
        presenter?.loadNewsDes(id!!)
    }

    override fun loadNewsDesSuccess(data: NewsDetailBean) {
        news_author.text = data.createUser
        news_content.text = data.content
        news_name.text = data.title
        news_time.text = data.createTime
        news_times.text = TimeUtil.transToYMd(TimeUtil.transToTimeStamp(data.createTime))
    }

    override fun loadNewsDesFail() {
    }


}